Xbasic
SQL::ConnectionToPropertyArray Method
Syntax
Result_Flag as L = ToPropertyArray(SQLStatement as C [, Arguments as SQL::Arguments,] Array as p[] [, RowsToCopy = -1 as N [, StartRow = 1 as N ]])
Arguments
- SQLStatementCharacter
The SQL query that selects the data to retrieve.
- ArgumentsSQL::Arguments
A SQL::Arguments object. One or more arguments to be resolved when the SELECT statement is executed.
- ArrayPointer
Pointer array to receive the retrieved data.
- RowsToCopy = -1Numeric
Default = -1 (all). The number of rows to copy.
- StartRow = 1Numeric
Default = 1 (first). The first row to copy.
Returns
- Result_FlagLogical
TRUE (.T.) if the operation was successful; otherwise FALSE (.F.).
Description
Fetch data to a property array using a SQL query.
You must dim the array first: DIM MyArray[1] as P
The ToPropertyArray() method fetches the results of the query to the DataArray property array. The property array will be initialized with columns matching the names of the fields retrieved.
Spaces are replaced with underscores.
Example
dim conn as SQL::Connection dim connString as C dim query as C dim args as SQL::Arguments dim array0 as P dim results as C query = "select firstname, lastname from customer where lastname > 'm'" connString = "{A5API='Access', FileName='c:\program files\a5v8\mdbfiles\alphasports.mdb'}" if .not. conn.open(connString) ui_msg_box("Error", conn.CallResult.text) end end if if .not. conn.ToPropertyArray(query, args, array, 5, 3) ui_msg_box("Error", conn.CallResult.text) conn.close() end end if results = property_to_string(array) ui_msg_box("Results", results) conn.close()
See Also